{extend name="base/main" /}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>会员卡批次 / 会员卡批次添加</h5>
        </div>
<div class="ibox-content">
    <form class="form-horizontal m-t" action="{:url('Member/add')}">
    <div class="layui-form-item">
        <label class="layui-form-label">批次名称</label>
        <div class="layui-input-inline">
            <input type="text" name="title" class="layui-input" placeholder="请输入批次名称">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">制卡数量</label>
        <div class="layui-input-inline">
           <input type="number" name="total_num" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">体验天数</label>
        <div class="layui-input-inline">
            <input type="number" name="use_day" class="layui-input">
        </div>
    </div>
        <div class="layui-upload" style="margin-left: 50px">
            <button type="button" class="layui-btn" id="test1">图标</button>
            <div class="layui-upload-list">
                <img class="layui-upload-img" id="demo1" width="100px" height="100px">
                <input type="hidden" name="img" id="qrcode">
                <p id="demoText"></p>
            </div>
        </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否激活</label>
        <div class="layui-input-inline">
            <input type="radio" name="status" value="1" title="冻结" checked>冻结
            <input type="radio" name="status" value="2" title="激活">激活
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="remark" placeholder="请输入备注" class="layui-textarea" style="height: 100px;width: 200px"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit>立即提交</button>
            <button class="btn btn-default historygo" type="button">返回</button>
        </div>
  </div>
</form>
        </div>
    </div>
</div>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            // layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
</script>
<script>
    layui.use(['upload', 'element', 'layer'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,element = layui.element
            ,layer = layui.layer;
        //常规使用 - 普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: '{:url("Member/upload")}' //改成您自己的上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
                element.progress('demo', '0%'); //进度条复位
                layer.msg('上传中', {icon: 16, time: 0});
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                if(res.code == 0){
                    $('#qrcode').val(res.data);
                    return layer.msg('上传成功');
                }
                //上传成功的一些操作
                //……
                $('#demoText').html(''); //置空上传失败的状态
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
            //进度条
            ,progress: function(n, elem, e){
                element.progress('demo', n + '%'); //可配合 layui 进度条元素使用
                if(n == 100){
                    layer.msg('上传完毕', {icon: 1});
                }
            }
        });
    });
</script>
{/block}